Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

567/user-data-dir-config #630

Merged
merged 11 commits into from
Feb 26, 2025
Merged

567/user-data-dir-config #630

merged 11 commits into from
Feb 26, 2025

Conversation

PaulDalek
Copy link
Contributor

Added the PUPPETEER_TEMP_DIR option, touch #567.

INFO:
Based on the @jszuminski's PR: #569.

@PaulDalek PaulDalek self-assigned this Feb 10, 2025
.refine(
(value) => {
// Simplified regex to match both absolute and relative paths
return /^(\.\/|\.\.\/|\/|[a-zA-Z]:\\|[a-zA-Z]:\/)?(([\w]+|-)[\\/]?)+$/.test(

Check failure

Code scanning / CodeQL

Inefficient regular expression High

This part of the regular expression may cause exponential backtracking on strings containing many repetitions of '0'.

Copilot Autofix AI 16 days ago

To fix the problem, we need to modify the regular expression to remove the ambiguity that can lead to exponential backtracking. Specifically, we should replace the [\w]+ pattern with a more precise pattern that avoids ambiguity. One way to achieve this is to use a non-capturing group with a negated character class to ensure that each character is matched in a deterministic way.

  • Replace the [\w]+ pattern with (?:[\w-]+) to ensure that the pattern matches sequences of word characters and hyphens without causing exponential backtracking.
  • Update the regular expression in the path validator function in the lib/envs.js file.
Suggested changeset 1
lib/envs.js

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/lib/envs.js b/lib/envs.js
--- a/lib/envs.js
+++ b/lib/envs.js
@@ -74,3 +74,3 @@
           // Simplified regex to match both absolute and relative paths
-          return /^(\.\/|\.\.\/|\/|[a-zA-Z]:\\|[a-zA-Z]:\/)?(([\w]+|-)[\\/]?)+$/.test(
+          return /^(\.\/|\.\.\/|\/|[a-zA-Z]:\\|[a-zA-Z]:\/)?((?:[\w-]+)[\\/]?)+$/.test(
             value
EOF
@@ -74,3 +74,3 @@
// Simplified regex to match both absolute and relative paths
return /^(\.\/|\.\.\/|\/|[a-zA-Z]:\\|[a-zA-Z]:\/)?(([\w]+|-)[\\/]?)+$/.test(
return /^(\.\/|\.\.\/|\/|[a-zA-Z]:\\|[a-zA-Z]:\/)?((?:[\w-]+)[\\/]?)+$/.test(
value
Copilot is powered by AI and may make mistakes. Always verify output.
@PaulDalek PaulDalek committed this autofix suggestion 16 days ago.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
…ression

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@PaulDalek PaulDalek linked an issue Feb 10, 2025 that may be closed by this pull request
@cvasseng cvasseng merged commit fd5edc3 into master Feb 26, 2025
2 of 3 checks passed
@cvasseng cvasseng deleted the 567/user-data-dir-config branch February 26, 2025 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

v4: make userDataDir configurable
2 participants